package com.zbkj.crmeb.merchant.admin.controller;

import com.crmeb.core.common.CommonResult;
import com.utils.vo.dateLimitUtilVo;
import com.zbkj.crmeb.store.response.DataLiveResponse;
import com.zbkj.crmeb.store.response.DataLiveSingleResponse;
import com.zbkj.crmeb.store.response.GoodsBoardResponse;
import com.zbkj.crmeb.store.service.DataLiveService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Collections;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/admin/mer/statistics/data")
@Api(tags = "商户后台-数据统计-数据实况")
public class MerDataLiveController extends AdminBaseController{

    @Autowired
    DataLiveService dataLiveService;

    /**
     * @Description: 返回实时信息
     * @param request
     * @Return: com.crmeb.core.common.CommonResult<com.zbkj.crmeb.store.response.DataLiveResponse>
     * @Author: wangzh
     * @Date: 2022/10/16 19:28
     */
    @GetMapping("/live")
    @ApiOperation("实时信息")
    public CommonResult<DataLiveResponse> getData(HttpServletRequest request) {
        return CommonResult.success(dataLiveService.getLiveData(Collections.singletonList(getMerId(request))));
    }

    /**
     * @Description: 整体面板
     * @param dateLimit
     * @param request
     * @Return: com.crmeb.core.common.CommonResult<com.zbkj.crmeb.store.response.DataLiveResponse>
     * @Author: wangzh
     * @Date: 2022/10/16 19:28
     */
    @GetMapping("/whole")
    @ApiOperation("整体看板")
    public CommonResult<DataLiveResponse> getWholeData(dateLimitUtilVo dateLimit, HttpServletRequest request){
        return CommonResult.success(dataLiveService.getWholeData(dateLimit, Collections.singletonList(getMerId(request))));
    }

    /**
     * 功能描述: 流量看板——用户访问量
     * @Param: [request]
     * @Return: com.crmeb.core.common.CommonResult<com.zbkj.crmeb.store.response.DataLiveSingleResponse>
     * @Author: wangzh
     * @Date: 2022/10/17 14:22
     */
    @GetMapping("/views")
    @ApiOperation("流量看板——用户访问量")
    public CommonResult<DataLiveSingleResponse> getFlowUserViewsData(HttpServletRequest request){
        return CommonResult.success(dataLiveService.getFlowUserViewsData(Collections.singletonList(getMerId(request))));
    }

    /**
     * 功能描述: 加购转化率与付款转化率
     * @Param: [request]
     * @Return: com.crmeb.core.common.CommonResult<java.util.Map<java.lang.String,com.zbkj.crmeb.store.response.DataLiveSingleResponse>>
     * @Author: wangzh
     * @Date: 2022/10/17 18:02
     */
    @GetMapping("/rate")
    @ApiOperation("加购转化率与付款转化率")
    public CommonResult<Map<String, DataLiveSingleResponse>> getFlowPurchaseData(HttpServletRequest request){
        return CommonResult.success(dataLiveService.getFlowPurchaseData(Collections.singletonList(getMerId(request))));
    }

    /**
     * 功能描述: 获取访客榜
     * @Param: [request]
     * @Return: com.crmeb.core.common.CommonResult<java.util.List<com.zbkj.crmeb.store.response.GoodsBoardResponse>>
     * @Author: wangzh
     * @Date: 2022/10/18 11:19
     */
    @GetMapping("/goods/visit")
    @ApiOperation("访客榜")
    public CommonResult<List<GoodsBoardResponse>> getGoodsBoardVisitData(HttpServletRequest request){
        return CommonResult.success(dataLiveService.getGoodsBoardVisitData(Collections.singletonList(getMerId(request))));
    }

    /**
     * 功能描述: 销量榜
     * @Param: [request]
     * @Return: com.crmeb.core.common.CommonResult<java.util.List<com.zbkj.crmeb.store.response.GoodsBoardResponse>>
     * @Author: wangzh
     * @Date: 2022/10/18 11:36
     */
    @GetMapping("/goods/sale")
    @ApiOperation("销量榜")
    public CommonResult<List<GoodsBoardResponse>> getGoodsBoardSalesVolumeData(HttpServletRequest request){
        return CommonResult.success(dataLiveService.getGoodsBoardSalesVolumeData(Collections.singletonList(getMerId(request))));
    }

    /**
     * 功能描述: 支付金额榜
     * @Param: [request]
     * @Return: com.crmeb.core.common.CommonResult<java.util.List<com.zbkj.crmeb.store.response.GoodsBoardResponse>>
     * @Author: wangzh
     * @Date: 2022/10/18 11:36
     */
    @GetMapping("/goods/pay")
    @ApiOperation("支付金额榜")
    public CommonResult<List<GoodsBoardResponse>> getGoodsBoardPayMoneyData(HttpServletRequest request){
        return CommonResult.success(dataLiveService.getGoodsBoardPayMoneyData(Collections.singletonList(getMerId(request))));
    }
}
